package org.example;

import org.example.dao.UserDao;
import org.example.servcie.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        //9月4号下午：
//        System.out.println( "Hello World!" );
//        ApplicationContext applicationContext=
//                new ClassPathXmlApplicationContext("application.xml");
//        UserDao userDao=(UserDao) applicationContext.getBean("userDao");
//        System.out.println(userDao.getName());

        //9月6号下午：
        ApplicationContext applicationContext=           //spring创建
                new ClassPathXmlApplicationContext("applicationconfig.xml");
        //app类和userservice类解耦
        UserService userService=(UserService) applicationContext.getBean("userService");
        //给UserDao赋值解决空指针问题
//        UserDao userDao=(UserDao) applicationContext.getBean("userDao");
//        userServcie.setUserDao(userDao);
        UserDao userDao=(UserDao) applicationContext.getBean("userDaoImpl");
        System.out.println(userService.getName());
    }
}
